import 'package:boss/ui/page/reportForm/collectionStatistics/page/collection_statistics_index.dart';
import 'package:boss/ui/page/reportForm/util/dialog.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/label_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:router/annotation.dart';

@RouterConfig(ChannelStatisticsPage.pageName)
class ChannelStatisticsPage extends StatefulWidget {
  static const pageName = '/channelStatisticsPage';

  @override
  _State createState() => _State("渠道销售统计");
}

class _State extends BaseState<ChannelStatisticsPage> {
  _State(String pageName) : super(pageName);

  GlobalKey<CollectionStatisticsIndexState> childKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CenterTitleAppBar(
        title: '渠道销售统计',
        actions: <Widget>[
          LabelButton(
            title: '发送邮箱',
            padding: EdgeInsets.only(left: 8, top: 2, bottom: 2),
            onTap: () {
              showChangeEmailAlert(
                context,
                title: '请输入邮箱',
                hintText: '请输入您的邮箱地址',
                onConfirmText: '提交',
                buttonOnly: true,
                onConfirm: (e) {
                  childKey.currentState.sendMailbox(e);
                },
              );
            },
          ),
        ],
      ),
      body: CollectionStatisticsIndex(key: childKey),
    );
  }
}
